Skip to content

Conversation

@matthewtlam
Copy link
Contributor

@matthewtlam matthewtlam commented Sep 11, 2025

The P4 program generally specifies a hash algorithm for use with action selectors. Previously, these did not show up in the P4Info since the choice of algorithm did not affect the control plane. However, we are now running into switches that support a new kind of algorithm called Dynamic Load Balancing (DLB) or Adaptive Routing (AR). See e.g. https://sonic.software/sai/group__SAIARS.html for some of the SAI APIs.

These algorithms have the interesting property that, instead of the controller defining the relative weights in the group, they are dynamically changing based on various measures of port quality. That means that this kind of algorithm does affect the control plane, since weights no longer make sense.

We wish to introduce this new field ,weights_disallowed, to the P4Info to denote to the control plane that programming will have no effects on the weights (and thus, to avoid confusion, should be rejected).

cc: @jonathan-dilorenzo, @smolkaj for vis

@chrispsommers
Copy link
Collaborator

Please provide a summary description, thanks.

@matthewtlam matthewtlam changed the title Support switch determining weights Support weights_determined_by_switch field in P4Info Sep 11, 2025
@matthewtlam
Copy link
Contributor Author

matthewtlam commented Sep 11, 2025

Other design considerations that we had include:

  • Expose a new type of hash algorithm in V1Model (needed for our purpose) and PSA (for standard compliance). The P4Info knob weights_determined_by_switch would then be set based on this hash algorithm.

Other questions

  • Do we care about some groups having a particular weight defined by the switch and then others groups that the switch can program?

EDIT: changed the link to reference P4C version

cc: @chrispsommers, @jafingerhut, @antoninbas

@antoninbas
Copy link
Member

@matthewtlam you shared an internal Google link

You could introduce a standard P4Runtime annotation to control whether that boolean should be set in the P4Info (similar to @max_group_size)

@jonathan-dilorenzo
Copy link
Contributor

Thanks @antoninbas! That would be our suggestion if we want to do this boolean approach. The main question, I think, would be if there is something more expressive we might want to put here instead, though I can't immediately think of other ways in which the hash algorithm might affect what the controller programs... I suppose a 'per-group' hash algorithm (including "You choose weights") would be a way to go (as we sort of discussed on Angela's PR), but I don't actually know of any switch with close to that expressive power ;).

@smolkaj
Copy link
Member

smolkaj commented Sep 12, 2025

"switch using its own hash algorithm to determine the weights"
I'm a bit confused by this part. Is it the job of the hash algorithm to determine the weights? Presumably it is the job of some sort of load balancing protocol/algorithm? And the hash algorithm is orthogonal?

@matthewtlam matthewtlam changed the title Support weights_determined_by_switch field in P4Info Support weights_disallowed field in P4Info Oct 10, 2025
@matthewtlam
Copy link
Contributor Author

@chrispsommers, @jafingerhut I've updated the PR to reflect what we discussed last meeting regarding dynamic load balancing and also updated the variable name to reflect this.

cc: @jonathan-dilorenzo, @smolkaj for viz

Signed-off-by: Matthew Lam <[email protected]>
Signed-off-by: Matthew Lam <[email protected]>
Signed-off-by: Matthew Lam <[email protected]>
Signed-off-by: Matthew Lam <[email protected]>
Signed-off-by: Matthew Lam <[email protected]>
Signed-off-by: Matthew Lam <[email protected]>
@matthewtlam
Copy link
Contributor Author

@chrispsommers and @jafingerhut I've updated the PR with some of the comments that were discussed during today's P4 WG meeting. Please take a look

Copy link
Collaborator

@chrispsommers chrispsommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chrispsommers
Copy link
Collaborator

@matthewtlam I just merged #560 so not sure if you need to rebase or not. I'm OK with this, but would like @jafingerhut to have a chance to do final review. Thanks for the contribution.

Copy link
Contributor

@jafingerhut jafingerhut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the one comment I made about a typo, this looks good to me.

Signed-off-by: Matthew Lam <[email protected]>
@matthewtlam
Copy link
Contributor Author

@chrispsommers @jafingerhut I fixed the typo, it should be ready for merge!

cc: @jonathan-dilorenzo

Copy link
Member

@smolkaj smolkaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this has LGTMs all around, going to merge.

@smolkaj smolkaj merged commit 1a72547 into p4lang:main Oct 14, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants